package com.ruoyi.syrw.domain.vo;

import cn.hutool.core.util.ObjUtil;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.ruoyi.common.annotation.ExcelDictFormat;
import com.ruoyi.common.convert.ExcelDictConvert;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.syrw.domain.BiExcelType;
import lombok.Data;

import java.util.Date;


/**
 * report与excel关系视图对象 syrw_ref_report_excel
 *
 * @author zyb
 * @date 2024-04-30
 */
@Data
@ExcelIgnoreUnannotated
public class RefReportExcelVo implements Comparable<RefReportExcelVo> {

    @Override
    public int compareTo(RefReportExcelVo o) {
        if (!o.getExcelIndex().equals(this.getExcelIndex())) {
            return this.getExcelIndex() - o.getExcelIndex();
        } else if (!o.getLabel().equals(this.label)) {
            return this.getLabel().compareTo(o.getLabel());
        }
//        else if (this.getExcelCreatTime().equals(o.getExcelCreatTime())) {
//            return this.getExcelCreatTime().compareTo(o.getExcelCreatTime());
//        }
        else {
            return this.getExcelId().compareTo(o.getExcelId());
        }
    }

    private static final long serialVersionUID = 1L;

    /**
     * 试验任务report_id
     */
    @ExcelProperty(value = "试验任务report_id")
    private Long reportId;

    /**
     * syrw_bi_jl_type中的jl_type_id（用来说明具体关联哪个表的excel）
     */
    @ExcelProperty(value = "syrw_bi_jl_type中的jl_type_id", converter = ExcelDictConvert.class)
    @ExcelDictFormat(readConverterExp = "用来说明具体关联哪个表的excel")
    private Long excelTypeId;

    /**
     * excel记录id
     */
    @ExcelProperty(value = "excel记录id")
    private Long excelId;

    /**
     * excel的顺序
     */
    private Integer excelIndex;

    private Date excelCreatTime;

    /**
     * 简称
     */
    private String label;

    /**
     * excelTypeName
     */
    private String excelTypeName;

    public void setVo(BiExcelType type) {
        if (ObjUtil.isNull(type)) {
            return;
        }
        this.label = type.getLabel();
        this.excelTypeName = type.getExcelTypeName();
        this.excelIndex = type.getTypeSort();
        this.excelCreatTime = type.getCreateTime();
    }

    /**
     * pageIndex excel的页码
     */
    private Long pageIndex;


}
